<?php 
    namespace Media\Entity;
    
    use Doctrine\ORM\Mapping as ORM;
    /**
     * Photo
     * 
     * @ORM\Entity(repositoryClass="Media\Repository\PhotoRepository") @ORM\Table(name="Photo")
    **/
    class Photo{
            /**
             * @ORM\GeneratedValue(strategy="IDENTITY")
             * @ORM\Id
             * @ORM\Column(name="id", type="bigint", nullable=true )
             * 
            **/
            public $id;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Application\Entity\Provider")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="provider_id", referencedColumnName="id")
             * })
             * 
            **/
            public $provider_id;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Application\Entity\Filter")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="filter_id", referencedColumnName="id")
             * })
             * 
            **/
            public $filter_id;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Application\Entity\User")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="user_uid", referencedColumnName="uid")
             * })
             * 
            **/
            public $user_uid;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Application\Entity\Comment")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="comment_id", referencedColumnName="id")
             * })
             *
             **/
            public $comment;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Media\Entity\Album")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="album_id", referencedColumnName="id", onDelete="CASCADE")
             * })
             * 
            **/
            public $album;
            /**
             * @var \string
             * @ORM\Column(name="name", type="string", length=255, nullable=true )
             * 
            **/
            public $name;
            /**
             * @var \string
             * @ORM\Column(name="path", type="string", length=255, nullable=false )
             * 
            **/
            public $path;
            /**
             * @var \string
             * @ORM\Column(name="description", type="string", nullable=false )
             * 
            **/
            public $description;
            /**
             * @var \bigint
             * @ORM\Column(name="source_album_facebook_id", type="bigint", nullable=true)
             * 
            **/
            public $source_album_facebook_id;
            /**
             * @var \DateTime
             * @ORM\Column(name="created_at", type="datetime", nullable=false )
             * 
            **/
            public $created_at;
            /**
             * @var \DateTime
             * @ORM\Column(name="modified_at", type="datetime", nullable=false )
             * 
            **/
            public $modified_at;
            /**
             * @var \string
             * @ORM\Column(name="type", type="string", length=255, nullable=false )
             * 
            **/
            public $type;
            /**
             * @var \Provider
             * @ORM\ManyToOne(targetEntity="Media\Entity\Photo")
             * @ORM\JoinColumns({
             *    @ORM\JoinColumn(name="original", referencedColumnName="id")
             * })
             * 
            **/
            public $original;
            
            public function createJson(){
                return $this->getJson();
            }
            
            public function getJson(){
                $row = array(
                		"id"=>$this->id,
                		"name"=> $this->name,
                		"image"=> $this->path,
                		"nb_marks"=> 0, //TODO
                		"original_id"=>$this->original==null?0:$this->original->id,
                		"desc"=> $this->description,
                		"created_at"=> $this->created_at!=null?$this->created_at->format("Y-m-d H:i:s"):"",
                		"modified_at"=> $this->modified_at!=null?$this->modified_at->format("Y-m-d H:i:s"):"",
                		"timestamp"=> $this->created_at!=null?$this->created_at->getTimestamp():"",//TODO
                );
                return $row;
            }
        }
